﻿

using HBase;
using hCommand;
using Net.http;
using Persistence;
using System.Collections.Generic;

namespace WebApi
{
    [FormAuthenticationFilter]

    [RoutePrefix("corewhloc")]
    public class CoreWhLocController : BaseApiController
    {
        ICoreWhLocServer coreWhLocServer = WMSDalFactray.getDal<ICoreWhLocServer>();

        //库位分页查询
        [HttpPost, Route("FindPage")]
        public BaseResult FindPage([FromBody] CoreWhLocDto dto)
        {
            Page<CoreWhLoc> info = coreWhLocServer.QueryLocPage(dto);
            return BaseResult.Ok(info);
        }
        //库位保存修改
        [HttpPost, Route("save"), ControlName("库位保存")]
        public BaseResult Save([FromBody] CoreWhLoc coreLoc)
        {
            if (coreLoc.id == 0)
            {
                return BaseResult.Error("库位不存在!");
            }
            string msg = WMSTransactionFacade.doLocAreaChangeEngine(coreLoc.id, coreLoc.areaId, coreLoc.ActiveStatus);
            if (string.IsNullOrEmpty(msg))
            {
                msg = "成功";
            }

            return BaseResult.Ok(msg);
        }

        //库位批量编辑
        [HttpPost, Route("BatchEdit/{areaid}"), ControlName("库位批量编辑")]
        public BaseResult BatchEdit([FromBody] List<long> locList, long areaid)
        {
             coreWhLocServer.batchUpdateLocScr(locList, areaid, -1);
            
            return BaseResult.Ok("成功！");
        }
    }
}